﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcps.Web.badinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int ID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(ID);
				}
			}
		}
			
	private void ShowInfo(int ID)
	{
		lcps.BLL.badinfo bll=new lcps.BLL.badinfo();
		lcps.Model.badinfo model=bll.GetModel(ID);
		this.lblID.Text=model.ID.ToString();
		this.txtbno.Text=model.bno;
		this.txtbtime.Text=model.btime.ToString();
		this.txtsupplier.Text=model.supplier;
		this.txtquestion.Text=model.question;
		this.txtdispose.Text=model.dispose;
		this.txtdisresult.Text=model.disresult;
		this.txtremark.Text=model.remark;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtbno.Text.Trim().Length==0)
			{
				strErr+="bno不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtbtime.Text))
			{
				strErr+="btime格式错误！\\n";	
			}
			if(this.txtsupplier.Text.Trim().Length==0)
			{
				strErr+="supplier不能为空！\\n";	
			}
			if(this.txtquestion.Text.Trim().Length==0)
			{
				strErr+="question不能为空！\\n";	
			}
			if(this.txtdispose.Text.Trim().Length==0)
			{
				strErr+="dispose不能为空！\\n";	
			}
			if(this.txtdisresult.Text.Trim().Length==0)
			{
				strErr+="disresult不能为空！\\n";	
			}
			if(this.txtremark.Text.Trim().Length==0)
			{
				strErr+="remark不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ID=int.Parse(this.lblID.Text);
			string bno=this.txtbno.Text;
			DateTime btime=DateTime.Parse(this.txtbtime.Text);
			string supplier=this.txtsupplier.Text;
			string question=this.txtquestion.Text;
			string dispose=this.txtdispose.Text;
			string disresult=this.txtdisresult.Text;
			string remark=this.txtremark.Text;


			lcps.Model.badinfo model=new lcps.Model.badinfo();
			model.ID=ID;
			model.bno=bno;
			model.btime=btime;
			model.supplier=supplier;
			model.question=question;
			model.dispose=dispose;
			model.disresult=disresult;
			model.remark=remark;

			lcps.BLL.badinfo bll=new lcps.BLL.badinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
